<?php
include(dirname(__FILE__) . "/account.php");
include(dirname(__FILE__) . "/../favorite-service-adapter.php");

$user_id = GetLoginId($_COOKIE['t']);
if (!$user_id || $user_id <= 0) {
  echo '{code : 1, reason:"未登录用户"}';
} else {
  $article_id = $_GET['id'];

  if ($article_id > 0) {
    $adapter = new FavoriteServiceAdapter();
    $code = $adapter->Add($user_id, $article_id);

    if ($code == 0) {
      echo '{code : 0, reason : "收藏成功"}';
    } else {
      echo '{code : 2, reason : "操作失败"}';
    }
  } else {
    echo '{code : 3, reason : "参数错误"}';
  }
}
?>
